package job.wangyihuyu;

import java.nio.channels.ScatteringByteChannel;
import java.util.Scanner;

/**
 * @author wq
 */
public class ShiZiZhan {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();


        int[][] arr = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                arr[i][j] = scanner.nextInt();
            }
        }


        int max = 0;
        int x = 0, y = 0;
        int sum = 0;

        for (int row = 0; row < n; row++) {
            max=0;
            sum=0;
            int cnt=0;
            boolean[] isRowDelete=new boolean[n];
            boolean[] isColDelete=new boolean[n];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (arr[i][j] == Integer.MIN_VALUE) {//已经删除
                        isRowDelete[j]=true;
                        isColDelete[i]=true;
                        continue;
                    }
                    sum = getSum(arr, i, j, n);
                    //System.out.println(sum);
                    if (sum >max) {
                        max = sum;
                        x = i;
                        y = j;
                    }
                }
            }
            delete(arr,x,y,n);
            for(int i=0;i<x;i++){
                if(isColDelete[i]){
                    x--;
                }
            }
            for(int j=0;j<y;j++){
                if(isRowDelete[j]){
                    y--;
                }
            }
            System.out.println((x+1)+" "+(y+1));

        }

    }

    public static int getSum(int[][] arr, int m, int n, int len) {
        int sum = 0;
        for (int i = 0; i < len; i++) {
            if (arr[m][i] == Integer.MIN_VALUE) {
                continue;
            }
            sum += arr[m][i]; //行
        }
        for (int j = 0; j < len; j++) {
            if (arr[j][n] == Integer.MIN_VALUE) {
                continue;
            }
            sum += arr[j][n]; //列
        }

        return sum-arr[m][n];
    }

    public static void delete(int[][] arr, int m, int n, int len) {
        for (int i = 0; i < len; i++) {
            arr[m][i] = Integer.MIN_VALUE; //行
        }
        for (int j = 0; j < len; j++) {
            arr[j][n] = Integer.MIN_VALUE; //列
        }
    }

}
